<%--

  User: 刘军海
  Date: 2014/11/12 15:42
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="st" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="j" uri="j/tags" %>

<st:page>
    <div id="toolbar">
        <a href="#" id="addStyle" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="addNew(this);">增加查询</a>
    </div>
    <table id="dg" style="width:100%;" class="easyui-datagrid" data-options="fit:true,showFooter:true
            ,pagination:true,toolbar:'#toolbar',singleSelect:true,pageSize:15,pageList:[15,20,30,50]">
        <thead data-options="frozen:true">
        <tr><th data-options="field:'queryId',formatter:optFormatter">操作</th></tr>
        </thead>
        <thead>
        <tr>
            <th data-options="field:'queryKey',width:90">查询key</th>
            <th data-options="field:'name',width:130">名称</th>
            <th data-options="field:'querySql',width:130">sql</th>
            <th data-options="field:'showByTree',width:80">是否TreeGrid</th>
            <th data-options="field:'multiColumnSortedSupported',width:80">支持多列排序</th>
            <th data-options="field:'pagingSupported',width:60">支持分页</th>
            <th data-options="field:'multiSelectSupported',width:60">支持行多选</th>
            <th data-options="field:'rowClick',width:100">行点击事件</th>
            <th data-options="field:'rowStyler',width:100">行格式化事件</th>

            <th data-options="field:'footerSupported',width:60">是否显示footer</th>
            <th data-options="field:'footerOptions',width:100">Footer选项</th>

            <th data-options="field:'dataHandlerClassName',width:120">处理类</th>
            <th data-options="field:'buildWhereMethodName',width:120">条件构造方法名</th>
            <th data-options="field:'columnMovingSupported',width:80">支持列拖拽</th>

            <th data-options="field:'userInfo',width:60,align:'center'">创建人</th>
            <th data-options="field:'addedTime',width:130,align:'center'">创建时间</th>
        </tr>
        </thead>
    </table>
    <script>
        var nodeId = "";
        function init(){
            nodeId = parent.nodeId;
            $("#dg").datagrid({url:"/user/sys/qmdManager?act=getlist",queryParams:{functionId:nodeId}});
        }
        function optFormatter(val,row){
            if(typeof val === "undefined"){
                return "";
            }
            var opt = "";
            opt = "<a href='javascript:void(0);' onclick=\"update(this,'"+val+"');\" >修改</a>";
            opt += " <a href='javascript:void(0);' onclick=\"del(this,'"+val+"');\" >删除</a>";
            opt += " <a href='javascript:void(0);' onclick=\"fieldE(this,'"+val+"');\" >编辑字段</a>";
            opt += " <a href='javascript:void(0);' onclick=\"editOpts(this,'"+val+"');\" >操作列表</a>";
            opt += " <a href='javascript:void(0);' onclick=\"refresh(this,'"+val+"');\" >刷新</a>";
            opt += " <a href='javascript:void(0);' onclick=\"review(this,'"+val+"');\" >预览</a>";
            return opt;
        }
        function reload(){
            $("#dg").datagrid("reload");
        }
        function addNew(sender){
            j.open("/user/sys/qmdManager?act=edit&functionId="+nodeId,"editWin",{title:"增加查询"},500,400);
        }
        function update(sender,val){
            j.open("/user/sys/qmdManager?act=edit&queryId="+val,"editWin",{title:"修改查询"},500,400);
        }
        function fieldE(sender,val){
            j.open("/user/sys/qmdManager?act=fe&queryId="+val,"fieldWin",{},1200,600);
        }
        //编辑操作列表
        function editOpts(sender,val){
            j.open("/user/pd?act=jsp&jsp=<j:des data="qmd/queryOpts"/>&queryId="+val,"opts",{},800,600);
        }
        function del(sender,id){
            if(window.confirm("确认删除吗?一旦删除则不能恢复!")){
                Http.post("/user/sys/qmdManager?act=delq",{queryId:id},function(data){
                    alert("删除成功!");
                    $("#dg").datagrid("reload");
                })
            }
        }
        function refresh(sender,id){
            if(window.confirm("确认要将修改后的数据刷新至缓存吗？")){
                Http.post("/user/sys/qmdManager?act=refresh",{queryId:id},function(data){
                    alert("成功刷新至缓存，可点击预览查看效果！");
                });
            }
        }
        function review(sender,val){
            j.open("/user/sys/qmdManager?act=review&queryId="+val,"reviewWin",{},960,390);
        }
    </script>
</st:page>